package com.tanhua.server.controller;

import com.tanhua.server.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author liuyp
 * @date 2021/01/31
 */
@RestController
@RequestMapping("/baidu")
public class BaiduController {
    @Autowired
    private BaiduService baiduService;

    /**
     * 上报地理位置
     * POST /baidu/location
     */
    @PostMapping("/location")
    public ResponseEntity saveLocation(@RequestBody Map map){
        //纬度
        Double latitude = (Double) map.get("latitude");
        //经度
        Double longitude = (Double) map.get("longitude");
        //位置名称
        String address = (String) map.get("addrStr");
        return baiduService.saveLocation(latitude, longitude, address);
    }
}